<?
	define("MISRESULT_BAD", 0);
	define("MISRESULT_PASS", 1);
	define("MISRESULT_QUEUE", 2);

	$thrift_host = "192.168.231.128";
	$thrift_port = "9090";
	$result = "";
	if (isset($_REQUEST["action"])) {
		$GLOBALS['THRIFT_ROOT'] =  dirname(__FILE__);

		require_once $GLOBALS['THRIFT_ROOT'].'/Thrift.php';
		require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
		require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
		require_once $GLOBALS['THRIFT_ROOT'].'/transport/THttpClient.php';
		require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
		require_once $GLOBALS['THRIFT_ROOT'].'/packages/mis/MISInterface.php';
		require_once $GLOBALS['THRIFT_ROOT'].'/packages/mis/mis_types.php';

		$socket = new TSocket($thrift_host, $thrift_port);
		$transport = new TBufferedTransport($socket, 1024, 1024);
		$protocol = new TBinaryProtocol($transport);
		$client = new MISInterfaceClient($protocol);
		$transport->open();

		$input = new MISRequest();
		$input->record_id = "";
		$input->user_id = "";
		$input->ip = "";
		$input->channel = "tt";
		$input->content = $_REQUEST["content"];

		$result = $client->check($input);
		//$result = "Result: ".$result;

		$transport->close();
	}
?>
<form action=? method=get>
<textarea name=content>
</textarea>
<br>
<input type=submit value="Check">
<input type=hidden name=action value="c">
</form>
<? echo $result;?>

<h2>Thrift Server</h2>
<pre>Host: <?=$thrift_host?>

Port: <?=$thrift_port?></pre>
